﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class InGameStateManager
{
    public enum StateType : int
    {
        SingleMyTurnState = 0,
        SingleOtherTurn,
        SingleFlyCannonBall,
    }

    private State _curState = null;
    private State _prevState = null;

	private StateType _stateType;

    private Dictionary<StateType, State> _dicState = new Dictionary<StateType, State>();

	public StateType GetStateType()
	{
		return _stateType;
	}

	public State GetState()
	{
		return _curState;
	}

    public void CreateState()
    {
        SingleMyTurnState SingleMyTurnState = new SingleMyTurnState();
        SingleFlyCannonBallState singleFlyCannonBallState = new SingleFlyCannonBallState();

        _dicState.Add(StateType.SingleMyTurnState, SingleMyTurnState);
        _dicState.Add(StateType.SingleFlyCannonBall, singleFlyCannonBallState);

    }

    public void ChangeState(StateType stateType)
    {
        if (_curState != null)
        {
            _curState.EndState();
            _prevState = _curState;
        }

		_stateType = stateType;

        if (_dicState.TryGetValue(stateType, out _curState) == true)
            _curState.EnterState();        
    }

    public void UpdateState(float fDT)
    {
        if (_curState != null)
            _curState.UpdateState(fDT);
    }

}
